
package mutsumimod.actions;

import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.common.DamageAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.GainStrengthPower;
import com.megacrit.cardcrawl.powers.StrengthPower;
import mutsumimod.powers.BreakPower;

public class LineCutDollAction extends BaseAction {

    private int magicNumber;

    public LineCutDollAction(int magicNumber) {
        this.magicNumber = magicNumber;
    }

    public void update() {
        AbstractPlayer p=AbstractDungeon.player;
        for(AbstractMonster mo : AbstractDungeon.getMonsters().monsters){
            if(!mo.isDeadOrEscaped()){
                int amount=0;
                if(mo.hasPower(BreakPower.POWER_ID)){
                    amount=mo.getPower(BreakPower.POWER_ID).amount*magicNumber;
                }
                if(amount>0){
                    addToTop(new ApplyPowerAction(mo, p, new StrengthPower(mo, -amount), -amount));
                    if (mo != null && !mo.hasPower("Artifact")) {
                        addToTop(new ApplyPowerAction(mo, p, new GainStrengthPower(mo, amount), amount));
                    }
                    addToTop(new DamageAction(mo,new DamageInfo(p,amount, DamageInfo.DamageType.HP_LOSS), AbstractGameAction.AttackEffect.SLASH_VERTICAL));
                }
            }
        }

        isDone = true;
    }
}
